<?php

namespace Admin\Controller;

use Base\BackController;

class MemberInfoController extends BackController {

	public function index(){

		$this->model = D('MemberInfo');
		$array = array();
		// $array['realname'] = I('create_name');
		// $array['phone'] = I('mobile');

		$array['firtime'] = I('firtime',false);
        $array['sectime'] = I('sectime',false);
		$array['nickname']= I('nick_name',false);
		$array['newstart']= I('newstart',false);
		$array['newend']= I('newend',false);
		$reslut = $this->model->getWinUser($array);
		// echo $this->model->getLastSql();

		$show = $reslut['show'];
		$this->assign('list',$reslut['list']);

		$this->assign('firtime',$array['firtime']);
		$this->assign('sectime',$array['sectime']);
		$this->assign('newstart',$array['newstart']);
		$this->assign('newend',$array['newend']);
		
		// var_dump($reslut['list']);die;
		$this->assign('create_name',$array['realname']);
		$this->assign('mobile',$array['phone']);
		$this->assign('nick_name',$array['nickname']);
		$this->assign('page', $show);
		$this->display();

	}
	public function daochu(){
		$this->model = D('MemberInfo');
		$array = array();
		// $array['realname'] = I('create_name');
		// $array['phone'] = I('mobile');
		$array['firtime'] = I('firtime',false);
        $array['sectime'] = I('sectime',false);
        $array['newstart'] = I('newstart',false);
        $array['sectime'] = I('sectime',false);
		$array['newend']= I('newend',false);
		$reslut = $this->model->getWinUser($array,65536);
		$data = array(array('ID', '微信用户openid', '昵称', '性别', '省份', '城市', '头像', '首次访问时间','最后访问时间'));

		foreach ($reslut['list'] as $key => $val) {
			$val['sex'] = $val['sex'];
			if($val['sex'] == 1){
				$val['sex'] ='男';
			}elseif($val['sex'] == 2){
				$val['sex'] ='女';
			}else{
				$val['sex'] ='未知';
			}
			if($val['create_time'] !=0)
			$val['create_time'] = date('Y-m-d H:i:s',$val['create_time']);
		    if($val['update_time'] !=0)
			$val['update_time'] = date("Y-m-d H:i:s",$val['update_time']);

			array_push($data, array($val['id'], $val['openid'], $val['nickname'] , $val['sex'], $val['province'], $val['city'], $val['headimgurl'],$val['create_time'],$val['update_time']));
		}

		$exeleObject = new \Admin\ORG\Excel();

        $exeleObject->download($data, 'MemberInfo');

	}
}